<template>
  <div class="event">
    <div class="home-echarts-bar-box">
      <el-scrollbar style="height: 100%">
        <div
          v-for="(item,index) in echartsList"
          :key="index"
          class="home-echarts-bar"
          :style="'z-index:' + (isShow[index]?3:0) "
        >
          <div :class="{'on':isShow[index]}" @click="show('open',index)" class="dash-box">
            <i
              v-if="isShow[index]"
              class="el-icon-circle-close-outline"
              @click.stop="show('close',index)"
            ></i>
            <div class="title">
              <div class="mask" @click.stop="show('close',index)"></div>
              <span>{{ item.title }}</span>
              <!-- <div class="indicator-month-event">
                <el-date-picker v-model="month[0]" type="month" class="month" placeholder="开始月"></el-date-picker>
                <el-date-picker v-model="month[1]" type="month" class="month" placeholder="结束月"></el-date-picker>
              </div>-->
            </div>
            <div class="echart">
              <div class="echart-inner">
                <echarts :data="item.data" class="echarts-item"></echarts>
                <!--在这个 echarts 组件里 item.data 就是配置   data是参数项 -->
              </div>
            </div>
          </div>
        </div>
      </el-scrollbar>
    </div>
  </div>
  <!--<map-box style="position:absolute;height: 78vh;width: 94vw;top: 0;left: 0;"></map-box>-->
</template>
<script>
import Echarts from "@/components/echarts/index";

export default {
  name: "monitor-index",
  components: {
    Echarts
  },
  data() {
    return {
      month: ["2018-12-31T16:00:00.000Z", "2019-05-31T16:00:00.000Z"],
      isShow: [],
      echartsList: [
        {
          title: "事件信息",
          data: {
            title: "",
            legend: {
              //设置图
              orient: "vertical",
              x: "left",
              icon: "rectangle",
              itemWidth: 30, // 设置宽度
              itemHeight: 30, // 设置高度
              itemGap: 30, // 设置间距
              padding: [30, 20, 20, 40],
              data: [
                "设备报警",
                "漏控信息",
                "事件上报",
                "客服信息",
                "事件录入"
              ],
              textStyle: {
                padding: [0, 0, 0, 10],
                color: "rgba(255,255,255,0.87)",
                fontSize: "20"
              }
            },
            series: [
              {
                name: "访问来源",
                type: "pie",
                selectedMode: "single",
                radius: [0, "30%"],

                label: {
                  normal: {
                    position: "inner"
                  }
                },
                labelLine: {
                  normal: {
                    show: false
                  }
                },
                data: [{ value: 1548, name: "事件总数" }]
              },
              {
                name: "访问来源",
                type: "pie",
                radius: ["40%", "55%"],

                data: [
                  { value: 335, name: "设备报警" },
                  { value: 310, name: "漏控信息" },
                  { value: 234, name: "事件上报" },
                  { value: 135, name: "客服信息" },
                  { value: 1048, name: "事件录入" }
                ]
              }
            ]
          }
        }
      ]
    };
  },
  methods: {
    getData() {
      overview2().then(res => {
        //console.log(res + "2222");
        // 处理拿到的数据
      });
    },
    selTime() {
      const loading = this.$loading({
        lock: true,
        text: "Loading",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)"
      });
      setTimeout(() => {
        loading.close();
      }, 800);
    },
    show(e, index) {
      //console.log(e, index);
      const th = this;
      function todo(isShow) {
        th.$set(th.isShow, index, isShow);
        //console.log(th.isShow);
      }

      if (e === "open" && th.isShow[index] === true) {
        return;
      }
      todo(e === "open");
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.indicator-month-event {
  display: flex;
  -webkit-box-align: center;
  align-items: center;
  -webkit-box-pack: justify;
  justify-content: space-between;
  padding: 0;
  position: absolute;
  right: 1rem;
  top: 0;
  width: 25vw;
}
.el-date-editor.el-input,
.el-date-editor.el-input__inner {
  margin-right: 0.55rem;
}
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
.map {
  position: absolute;
  top: 0.5rem;
  left: calc(26vw + 0.5rem);
  right: calc(26vw + 0.5rem);
  bottom: calc(23% + 0.5rem);
  overflow: hidden;

  background-size: auto 110%;
  span {
    font-size: 1.3em;
    margin: 0 5px;
  }
  .list {
    position: absolute;
    background: rgba(0, 0, 0, 0.1);
    font-size: 0.8rem;
    padding: 0.5rem 1.5rem 0.5rem 2rem;
    line-height: 1.3;
    .title {
      line-height: 1.4;
      margin-bottom: 0.2rem;
      font-size: 1rem;
      color: #00ccff;
      &:before {
        content: "";
        position: absolute;
        width: 16px;
        height: 16px;
        border-radius: 100%;
        border: 2px solid #cc66ff;
        background: #6600cc;
        top: calc(1.2rem - 8px);
        left: 0.7rem;
      }
      &.title-2:before {
        content: "";
        position: absolute;
        width: 16px;
        height: 16px;
        border-radius: 100%;
        border: 2px solid #ff3333;
        background: #663300;
        top: calc(1.2rem - 8px);
        left: 0.7rem;
      }
    }
    .color {
      color: #00ccff;
    }
    i,
    b {
      width: 1px;
      height: 20px;
      position: absolute;
      background: #00ccff;
      &.l {
        left: 0;
      }
      &.t {
        top: 0;
      }
      &.r {
        right: 0;
      }
      &.b {
        bottom: 0;
      }
    }
    b {
      height: 1px;
      width: 20px;
    }
  }
}
.home-echarts-bar-box {
  position: absolute;
  width: 39.4vw;
  right: 0.5rem;
  top: 0;
  bottom: 0;
  overflow-x: auto;
  .home-echarts-bar {
    cursor: pointer;
    z-index: 2;
    height: 46vh;
    position: relative;
    // margin-bottom: 1rem;
    .dash-box {
      height: 100%;
      .title {
        height: 2.6rem;
        text-align: left;
        line-height: 2.6rem;
        color: #00ffff;
        font-size: 1.25rem;
        text-indent: 1rem;
        background: rgba(85, 74, 189, 0.3);
        border-bottom: 1px solid #0cf;
      }
      .echart {
        height: calc(100% - 2rem);
        padding: 0.5rem;
        &-inner {
          height: 235.714%;
          width: 230.77%;
          transform: scale(0.433333, 0.42424242);
          transform-origin: 0 0;
        }
      }
      &.on {
        position: fixed;
        top: 15vh;
        transform: none !important;
        width: 60vw;
        height: 66vh;
        right: 50%;
        margin-bottom: -27vh;
        margin-right: -30vw;
        border-radius: 2px;
        border: 2px solid rgba(27, 164, 226, 0.85);
        background: rgba(24, 10, 67, 0.95);
        z-index: 4;
        &:before {
          opacity: 0;
          transition: opacity 0.3s;
        }
        .mask {
          display: block;
        }
        .title {
          height: 4rem;
          line-height: 4rem;
          font-size: 1.5rem;
        }
        transform: none !important;
        width: 60vw;
        height: 66vh;
        .echart {
          &-inner {
            height: 100%;
            width: 100%;
            transform: none;
          }
        }
      }
      .mask {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        background: rgba(0, 0, 0, 0.1);
        z-index: -1;
      }
    }
    .el-icon-circle-close-outline {
      position: absolute;
      top: -16px;
      right: -16px;
      font-size: 24px;
      width: 32px;
      height: 32px;
      line-height: 32px;
      text-align: center;
      color: #dddddd;
      &:hover {
        color: #fff;
      }
      &:after {
        content: "";
        position: absolute;
        width: 20px;
        height: 20px;
        border-radius: 100%;
        background: rgba(24, 10, 67, 0.95);
        top: 6px;
        left: 6px;
        z-index: -1;
      }
    }
  }
}

.echarts-item {
  &-0 {
    bottom: calc(66% + 0.5rem + 5vh);
  }
  &-1 {
    bottom: calc(33% + 0.5rem + 2.5vh);
  }
  &-2 {
    bottom: 0.5rem;
  }
}

.indicator {
  position: absolute;
  left: 0.5rem;
  top: -1.5rem;
  width: 26vw;
  height: 65%;
  &-title {
    display: flex;
    span {
      font-size: 1rem;
      line-height: 1.2rem;
      padding: 0.5rem 1.5rem 0.5rem 0.5rem;
      background-size: 100% 100%;
    }
  }
  .value-0 {
    color: #ff33ff;
  }
  .value-1 {
    color: #33ff33;
  }
  .value-2 {
    color: #ffcc33;
  }
  &-month {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0.5rem;
    .month {
      width: calc(50% - 50px);
    }
  }
  &-main {
    height: calc(100% - 7rem);
    > div {
      height: 25%;
      padding-top: 0.3rem;
      position: relative;
      .title {
        font-size: 0.825rem;
        height: 25%;
        display: flex;
        align-items: center;
        color: #00ffff;
        padding-left: 0.8rem;
      }
      .main {
        height: 70%;
        display: flex;
        align-items: center;
        padding: 0.3rem 0;
        li {
          height: 100%;
          width: calc(100% / 3 - 0.666667px);
          position: relative;
          margin-left: 1px;
          &:after {
            content: "";
            display: block;
            position: absolute;
            width: 1px;
            top: 20%;
            right: -1px;
            height: 60%;
            background: #00beea;
          }
          &:last-child:after {
            content: none;
          }
          .label {
            height: 45%;
            display: flex;
            justify-content: center;
            font-size: 0.75rem;
          }
          .value {
            height: 65%;
            display: flex;
            justify-content: center;
            font-size: 1.5rem;
          }
        }
      }
      &:after {
        content: "";
        display: block;
        height: 1px;
        width: 84%;
        position: absolute;
        background: #00ccff;
        left: 8%;
        bottom: -1px;
      }
      &:last-child:after {
        content: none;
      }
    }
  }
}

.quality {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  width: 26vw;
  height: 36%;
  &-title {
    font-size: 1rem;
    line-height: 2.4rem;
    padding-left: 0.5rem;
    background: #192790;
  }
  &-main {
    width: 133.3333%;
    transform: scale(0.75, 0.75);
    height: calc(133.3333% - 3.4rem);
    transform-origin: 0 0;
  }
}

.marketing {
  padding: 1rem;
  position: absolute;
  left: 28.5%;
  bottom: 0.5rem;
  width: 43%;
  height: 23%;
  display: flex;
  .marketing-item {
    width: 50%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    .left {
      margin-right: 0.5rem;
      width: 14vh;
      height: 100%;
    }
    .right {
      padding-bottom: 1.2rem;
    }
  }
}

.dash-box {
  border: 1.2px solid #00ccff;
  background: rgba(0, 0, 255, 0.15);
  box-shadow: 0 0 0.5rem #1800ff;
}

.echarts-item {
  height: 100%;
  .echarts-title {
    text-align: center;
    font-size: 1.3rem;
    height: 2.6rem;
    line-height: 1.8rem;
  }
}

.topList {
  display: flex;
  li {
    width: 33.33%;
    color: #00ccff;
    font-size: 1.1rem;
    span {
      font-size: 1.3rem;
      color: #33ff33;
    }
    &:last-child span {
      color: #ffcc33;
    }
    &:first-child span {
      color: #ff33ff;
    }
  }
}
</style>
<style rel="stylesheet/scss" lang="scss">
.month {
  .el-input__inner {
    padding-right: 0 !important;
    background: rgba(0, 0, 0, 0.5);
    padding-left: 20px;
    height: 2rem;
    line-height: 2rem;
    border-radius: 0;
  }
}

.el-table thead.is-group th,
.el-table,
.el-table__expanded-cell,
.el-table th,
.el-table tr {
  background: transparent;
}

.el-table,
.el-table thead {
  font-size: 1.2rem;
  color: #fff;
  text-align: center;
}

.el-table thead {
  color: #e78a20;
  text-align: center;
}

.el-table .cell {
  text-align: center;
}

.el-table--enable-row-hover .el-table__body tr:hover > td {
  background: rgba(255, 255, 255, 0.15);
}

.el-progress--circle .el-progress__text {
  font-size: 2rem !important;
  color: #ff33ff;
}
</style>
